package paidaxing.blog.common.utils;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

// blog-common/src/main/java/paidaxing/blog/common/utils/RequestHolder.java
/**
 * 请求上下文
 *
 * @author heefM
 * @date 2025-10-18
 */
@Component
public class RequestHolder {
    
    private static final ThreadLocal<HttpServletRequest> REQUEST_HOLDER = new ThreadLocal<>();
    
    public static void setRequest(HttpServletRequest request) {
        REQUEST_HOLDER.set(request);
    }
    
    public static HttpServletRequest getRequest() {
        return REQUEST_HOLDER.get();
    }
    
    public static void remove() {
        REQUEST_HOLDER.remove();
    }
}

